using Entitas;
using System.Collections.Generic;

public sealed class ProcessMoveInputSystem : ReactiveSystem {

    public ProcessMoveInputSystem(Contexts contexts) : base(contexts.input) {
        _contexts = contexts;
    }

    protected override Collector GetTrigger(Context context) {
        return context.CreateCollector(InputMatcher.MoveInput);
    }

    protected override bool Filter(Entity entity) {
        // TODO Entitas 0.36.0 Migration
        // ensure was: 
        // exclude was: 

        return true;
    }


    readonly Contexts _contexts;

    

    protected override void Execute(List<Entity> entities) {
        var input = entities[entities.Count - 1];
        var ownerId = input.inputOwner.playerId;

        var e = _contexts.core.GetEntityWithPlayerId(ownerId);

        // TODO Speed Shoud be configurable
        e.ReplaceVelocity(input.moveInput.direction.normalized * 0.3f);
    }
}
